define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'master.master/index',
        add_url: 'master.master/add',
        edit_url: 'master.master/edit',
        delete_url: 'master.master/delete',
        export_url: 'master.master/export',
        audit_url: 'master.master/changeAudit',
        examine_member_url: 'master.master/examineMember',
        bind_member_url: 'collage.collage/memberIndex',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                cols: [[
                    {type: 'checkbox', width: 50},
                    {field: 'id', title: 'ID', width: 60, search: 'false'},
                    {field: 'user.avatar_url', title: '团长用户id', search: 'false', templet: ea.table.image},
                    {field: 'true_name', title: '团长真实姓名', search: 'false'},
                    {field: 'mobile', title: '手机号', search: 'false'},
                    {field: 'delivery_fee', title: '配送费', search: 'false'},
                    {field: 'register_time', title: '申请时间', search: 'false'},
                    {field: 'audit_time', title: '审核时间', search: 'false'},
                    {
                        field: 'pay_mode', title: '付款方式', templet: function (d) {
                            if (d.pay_mode == 0) {
                                return '微信支付';
                            }
                        }
                        , search: 'false'
                    },
                    {
                        field: 'audit_status', title: '审核状态', templet: function (d) {
                            if (d.audit_status == 0) {
                                return '<span class="layui-badge layui-bg-orange">待审核</span>';
                            }
                            if (d.audit_status == 1) {
                                return '<span class="layui-badge layui-bg-green">审核通过</span>';
                            }
                            if (d.audit_status == 2) {
                                return '<span style="background-color: red" class="layui-badge">审核未通过</span>';
                            }
                        }
                        , search: 'select'
                        , selectList: {0: '待审核', 1: '审核通过', 2: '审核未通过'}
                    },
                    {
                        field: 'status', title: '团长状态', templet:ea.table.switch
                    },
                    {
                        field: 'audit_status', width: 200, title: '审核', templet: ea.table.tool, operat: [
                            [{
                                text: '审核通过',
                                title: "确定要执行此操作吗？",
                                url: 'master.master/passAudit',
                                field: 'id',
                                method: 'request',
                                class: 'layui-btn layui-btn-xs layui-btn-normal',
                            }, {
                                text: '审核不通过',
                                title: "确定要执行此操作吗？",
                                url: 'master.master/noPassAudit',
                                method: 'request',
                                class: 'layui-btn layui-btn-xs layui-btn-danger',
                            }]
                        ],
                        search: 'false'
                    },
                    {field: 'audit_time', title: '时间范围', search: 'range', hide: true},
                    {
                        width: 300, title: '操作', templet: ea.table.tool, operat: [
                            [
                                {
                                    text: '绑定核销员',
                                    url: 'collage.collage/MemberIndex',
                                    field: 'id',
                                    method: 'open',
                                    class: 'layui-btn layui-btn-xs layui-btn-normal',
                                }, {
                                    text: '查看核销员',
                                    title: "查看核销员",
                                    url: 'collage.collage/collageMember',
                                    method: 'open',
                                    class: 'layui-btn layui-btn-xs layui-btn-normal',
                                }, {
                                    text: '绑定商品',
                                    title: "绑定商品",
                                    url: 'master.master/noPassAudit',
                                    method: 'request',
                                    class: 'layui-btn layui-btn-xs layui-btn-normal',
                                }
                            ],
                            'edit'
                        ]
                    },
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});